<?php

//require_once './config/config.php';
require_once './config/config.php';
class Db {

    static $connection;
    public function getconnection() {
        if (!isset(self::$connection)) { 
            self::$connection = mysql_connect(DB_HOST . ":" . DB_PORT, DB_USER, DB_PASS,PER_PAGE) or die(mysql_error());
            mysql_select_db(DB_NAME, self::$connection);
        }
        return self::$connection;
    }

    public function query($query) {
        mysql_query('SET NAMES utf8', self::$connection);
        $data = mysql_query($query, self::$connection);
        $rows = array();
        while ($row = mysql_fetch_assoc($data)) {
            $rows[] = $row;
        }return $rows;
    }

}

?>